<script setup lang="ts">
import { ref } from 'vue';
import { AUTHORZATION_NAME, AUTHORZATION_COLOR } from '@/constants/data';

const props = defineProps({
  data: {
    type: Object as any,
    default: () => {
      return {};
    },
  },
});

const emits = defineEmits(['detail', 'update']);

const list = ref([
  { icon: 'item-user02', value: '陌生人', key: 'user' },
  { icon: 'item-rate', value: '76.5%', key: 'rate' },
  { icon: 'item-position', value: '四川省成都市武侯区佳灵路323号', key: 'position' },
]);

const toDetail = () => {
  emits('detail', props.data);
};
const toEdit = () => {
  emits('update', props.data);
};
</script>

<template>
  <div class="item-view">
    <div class="content" @click="toDetail">
      <div class="info">
        <!-- <div v-for="(item, index) in list" :key="index" class="item">
          <svg-icon class="item-icon" :name="item.icon"></svg-icon>
          <div class="value">{{ item.value }}</div>
        </div> -->
        <div class="item">
          <svg-icon class="item-icon" name="item-user02"></svg-icon>
          <div class="smart-name">{{ data.name }}</div>
        </div>
        <div class="item">
          <svg-icon class="item-icon" name="item-authorization"></svg-icon>
          <div class="smart-authorization" :style="{ color: AUTHORZATION_COLOR[data.authorization] }">
            {{ AUTHORZATION_NAME[data.authorization] }}
          </div>
        </div>
        <div class="item">
          <svg-icon class="item-icon" name="item-version"></svg-icon>
          <div class="smart-authorization">{{ data.version }}</div>
        </div>
        <div class="item">
          <svg-icon class="item-icon" name="item-dataInfo"></svg-icon>
          <div class="smart-authorization">{{ data.dataInfo }}</div>
        </div>
      </div>
    </div>
    <div class="footer" @click="toEdit">
      <svg-icon class="footer-svg" name="item-data"></svg-icon>
      <t-link theme="primary" style="margin-left: 8px; font-size: 11px; line-height: 14px" underline>默认参数</t-link>
    </div>
  </div>
</template>

<style lang="less" scoped>
.item-view {
  width: 100%;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e9e9e9;
  padding: 0 12px;
  cursor: pointer;
  box-shadow: 3px 22px 50px -2px rgb(121 120 130 / 15%);

  .content {
    height: calc(100% - 48px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    box-sizing: border-box;
    border-bottom: 1px solid #c6ced9;

    .face-icon {
      height: 100%;
    }

    .info {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      padding: 2px 0;
      gap: 10px;

      .item {
        display: flex;
        align-items: center;
        gap: 9px;

        .item-icon {
          width: 16px;
          height: 16px;
        }

        .value {
          font-size: 12px;
          line-height: 16px;
          color: #2d3748;
        }
        .smart-name {
          color: #0f64ff;
          font-size: 11px;
          line-height: 23px;
          padding: 0 6px;
          background: #d2e1fc;
          border-radius: 3px;
          border: 1px solid #0f64ff;
        }
      }
    }
  }

  .footer {
    height: 27px;
    display: flex;
    align-items: center;
    justify-content: center;
    .footer-svg {
      width: 14px;
      height: 14px;
    }
  }
}
</style>
